
// Keep COMMANDS format NOT changed and upto date! It is used for parsing API names in API usage page.

var NUMERIC_VALUES = ["from", "to", "sensorType", "dataType", "keys", "units", "fixtureId"];

var COMMANDS =
    [

        "_______ Casambi public API Access _______",

        {
            method: "POST",
            path: "/v1/users/session",
            title: "Create user session",
            noSessionKey: true,
            hasInput: true,
            inputExample: { "email":"", "password": "" },
            inputHelp: { "email":"name@address.com", "password": "password" },
            help: 'Create Casambi user (site account) session identified by email & password, requires use of API key (Header: X-Casambi-Key). ',
            responseExample: {
                "sessionId": "hJK65SenmlL2354y.P822D76HufewNSloo780PvU-78DwdmnMA8exzIo9.mmNWD23whEqbPOsl11hjjWo03___",
                "sites": {
                    "Rg5alx4BF41lSU2jK4r7T0Q7X0i00mQ": {
                        "name": "Playground",
                        "address": "",
                        "role": "ADMIN",
                        "networks": {
                            "j34asrSb66qE3conlXSvXySR0923as4f": {
                                "id": "j34asrSb66qE3conlXSvXySR0923as4f",
                                "mac": "b02ef7956be2",
                                "name": "Demo Room",
                                "type": "OPEN",
                                "grade": "EVOLUTION",
                                "role": "ADMIN"
                            },
                            "VcrTwqLZJ26UYMXxTClmpfZxELcrPUAa": {
                                "id": "VcrTwqLZJ26UYMXxTClmpfZxELcrPUAa",
                                "mac": "g4a1a3251f77",
                                "name": "Dev Network",
                                "type": "OPEN",
                                "grade": "EVOLUTION",
                                "role": "ADMIN"
                            }
                        }
                    }
                },
                "networks": {
                    "VcrTwqLZJ26UYMXxTClmpfZxELcrPUAa": {
                        "id": "VcrTwqLZJ26UYMXxTClmpfZxELcrPUAa",
                        "mac": "g4a1a3251f77",
                        "name": "Dev Network",
                        "type": "OPEN",
                        "grade": "EVOLUTION",
                        "role": "ADMIN"
                    }
                }
            }
        },
        {
            method: "POST",
            path: "/v1/networks/session",
            title: "Create network session",
            noSessionKey: true,
            hasInput: true,
            inputExample: { "email":"", "password": "" },
            inputHelp: { "email":"name@address.com", "password": "password" },
            help: 'Create network session identified by email & password, requires use of API key (Header: X-Casambi-Key). ',
            consoleNote: "On successful request returned JSON object will contain related network data indexed by networkId.",
            responseExample: {
                "VcrTwqLZJ26UYMXxTClmpfZxELcrPUAa": {
                    "id": "VcrTwqLZJ26UYMXxTClmpfZxELcrPUAa",
                    "mac": "g4a1a3251f77",
                    "name": "Dev Network",
                    "type": "OPEN",
                    "grade": "EVOLUTION",
                    "sessionId": "KDRmwOqerOsTyrr0x9HLrGFe1nknEk3oRoT-Kz3DJ.wx97MTXQXC.ZbWwqt9ze0KwC6h3GCTlPsUemX8uvK5Ow__"
                }
            }
        },

        "_______ Casambi public API Network _______",

        {
            method: "GET",
            path: "/v1/networks/{id}",
            title: "Request network information",
            params: {"id": ""},
            inputHelp: { "id": "networkId"},
            help: 'Retrieves network information identified by network ID, requires use of API key and sessionId (Header: X-Casambi-Key, X-Casambi-Session). \
            Note that if unit (item of units list) is part of a group (groupId > 0) it will have position value of 0 as the actual position within the group will be found in related group information. \
            See groups list of network data to find the actual position info of the group and its units.',
            responseExample: {
                "id": "j34asrSb66qE3conlXSvXySR0923as4f",
                "name": "Demo Room",
                "revision": 125,
                "grade": "EVOLUTION",
                "mac": "b02ef7956be2",
                "gateway": {
                    "name": "Demo iPad"
                },
                "type": "OPEN",
                "timezone": "Europe/Helsinki",
                "photos": [
                    {
                        "name": "Photo",
                        "controls": [],
                        "image": "iR4aIP3vXcB348Pijif2d4Y7AnowFbdD",
                        "position": 0
                    },
                    {
                        "name": "Photo",
                        "controls": [],
                        "image": "KLejfitLiEFeiUnhak6ID69VzJhvWYER",
                        "position": 1
                    }
                ],
                "units": {
                    "12": {
                        "id": 12,
                        "address": "8y0dfc3a5e41",
                        "name": "CBM #5656",
                        "position": 0,
                        "fixtureId": 5656,
                        "groupId": 3,
                        "labels": {},
                        "type": "Luminaire"
                    },
                    "15": {
                        "id": 15,
                        "address": "aab3e63c069a",
                        "name": "aBc (PIR)",
                        "position": 3,
                        "fixtureId": 1202,
                        "groupId": 0,
                        "labels": {},
                        "type": "Sensor"
                    },
                    "18": {
                        "id": 18,
                        "address": "dg33d6079c30",
                        "name": "TestZXY",
                        "image": "7Fw3whiOxsfuE6GTR6utJl8OEAPkOd3",
                        "position": 4,
                        "fixtureId": 5124,
                        "groupId": 0,
                        "labels": {},
                        "type": "Luminaire"
                    }
                },
                "scenes": {
                    "1": {
                        "name": "Timer",
                        "id": 1,
                        "position": 0,
                        "icon": 0,
                        "color": "#FFFFFF",
                        "type": "REGULAR",
                        "hidden": false,
                        "units": {
                            "12": {
                                "id": 12
                            }
                        }
                    },
                    "4": {
                        "name": "Presence",
                        "id": 2,
                        "position": 1,
                        "icon": 0,
                        "color": "#06FF29",
                        "type": "REGULAR",
                        "hidden": false,
                        "units": {
                            "18": {
                                "id": 18
                            }
                        }
                    }
                },
                "groups": {
                    "3": {
                        "id": 3,
                        "name": "Demo Group",
                        "position": 2,
                        "units": [
                            {
                                "0": 12,
                                "position": 0
                            }
                        ]
                    }
                }
            }
        },
        {
            method: "GET",
            path: "/v1/networks/{id}/units",
            title: "Request network unit list",
            params: {"id":""},
            inputHelp: { "id": "networkId"},
            help: 'Retrieves information of units in network identified by network ID, requires use of API key and sessionId (Header: X-Casambi-Key, X-Casambi-Session). \
            Note that if unit is part of a group (groupId > 0) it will have position value of 0 as the actual position within the group will be found in related group information.',
            responseExample: {
                "12": {
                    "id": 12,
                    "address": "8y0dfc3a5e41",
                    "name": "CBM #5656",
                    "position": 0,
                    "fixtureId": 5656,
                    "groupId": 3,
                    "labels": {},
                    "type": "Luminaire"
                },
                "15": {
                    "id": 15,
                    "address": "aab3e63c069a",
                    "name": "aBc (PIR)",
                    "position": 3,
                    "fixtureId": 1202,
                    "groupId": 0,
                    "labels": {},
                    "type": "Sensor"
                },
                "18": {
                    "id": 18,
                    "address": "dg33d6079c30",
                    "name": "TestZXY",
                    "image": "7Fw3whiOxsfuE6GTR6utJl8OEAPkOd3",
                    "position": 4,
                    "fixtureId": 5124,
                    "groupId": 0,
                    "labels": {},
                    "type": "Luminaire"
                }
            }
        },
        {
            method: "GET",
            path: "/v1/networks/{networkId}/units/{unitId}/state",
            title: "Request network unit state",
            params: { "networkId":"", "unitId": "" },
            inputHelp: { "networkId": "networkId", "unitId": "unitId" },
            help: 'Retrieves information of unit state in network identified by network ID and unit ID, requires use of API key and sessionId (Header: X-Casambi-Key, X-Casambi-Session). \
            Note that if unit is part of a group (groupId > 0) it will have position value of 0 as the actual position within the group will be found in related group information.',
            responseExample: {
                "id": 18,
                "address": "dfhe6079c30",
                "name": "TestUnit",
                "image": "456ghkOxsfuE6GTR6utJl8OEAPkSqh",
                "position": 4,
                "fixtureId": 16574,
                "groupId": 0,
                "priority": 3,
                "scene": 0,
                "on": true,
                "online": true,
                "condition": 134,
                "status": "status_message",
                "activeSceneId": 4,
                "controls": [
                    [
                        {
                            "type": "Dimmer",
                            "value": 1
                        },
                        {
                            "source": "XY",
                            "type": "Colorsource"
                        },
                        {
                            "x": 0.14753297508549096,
                            "y": 0.13727405959941377,
                            "rgb": "rgb(136, 255, 255)",
                            "type": "Color"
                        },
                        {
                            "tw": 23.52941,
                            "min": 2700,
                            "max": 6000,
                            "type": "CCT",
                            "value": 6000,
                            "level": 1
                        }
                    ]
                ],
                "dimLevel": 1,
                "type": "Luminaire"
            }
        },
        {
            method: "GET",
            path: "/v1/networks/{networkId}/state",
            title: "Request network state",
            params: { "networkId":"" },
            inputHelp: { "networkId": "networkId" },
            help: 'Retrieves information of network state identified by network ID, requires use of API key and sessionId (Header: X-Casambi-Key, X-Casambi-Session). \
            Note that if unit is part of a group (groupId > 0) it will have position value of 0 as the actual position within the group will be found in related group information.',
            responseExample: {
                "id": "j34asrSb66qE3conlXSvXySR0923as4f",
                "name": "Demo Room",
                "revision": 125,
                "grade": "EVOLUTION",
                "mac": "b02ef7956be2",
                "gateway": {
                    "name": "Demo iPad"
                },
                "type": "OPEN",
                "timezone": "Europe/Helsinki",
                "dimLevel": 0.5,
                "activeScenes": [
                    3,
                    4
                ],
                "photos": [
                    {
                        "name": "Photo",
                        "controls": [],
                        "image": "iR4aIP3vXcB348Pijif2d4Y7AnowFbdD",
                        "position": 0
                    },
                    {
                        "name": "Photo",
                        "controls": [],
                        "image": "KLejfitLiEFeiUnhak6ID69VzJhvWYER",
                        "position": 1
                    }
                ],
                "units": {
                    "15": {
                        "id": 15,
                        "address": "mjy44363c069a",
                        "name": "Sensor Z",
                        "position": 4,
                        "fixtureId": 45602,
                        "groupId": 0,
                        "priority": 0,
                        "scene": 0,
                        "on": false,
                        "online": false,
                        "condition": 0,
                        "status": "ok",
                        "activeSceneId": 0,
                        "controls": [
                            [
                                {
                                    "type": "Presence",
                                    "status": "absent"
                                },
                                {
                                    "level": 0,
                                    "type": "Lux",
                                    "value": 0
                                },
                                {
                                    "type": "Switch"
                                }
                            ]
                        ],
                        "details": {
                            "_name": "ccb3e63c069a",
                            "OEM": "Tridonic GmbH & Co KG",
                            "fixture_model": "bDW (PIR)"
                        },
                        "dimLevel": 0,
                        "type": "Sensor"
                    },
                    "18": {
                        "id": 18,
                        "address": "dfhe6079c30",
                        "name": "TestUnit",
                        "image": "456ghkOxsfuE6GTR6utJl8OEAPkSqh",
                        "position": 4,
                        "fixtureId": 16574,
                        "groupId": 0,
                        "priority": 3,
                        "scene": 0,
                        "on": true,
                        "online": true,
                        "condition": 134,
                        "status": "status_message",
                        "activeSceneId": 4,
                        "controls": [
                            [
                                {
                                    "type": "Dimmer",
                                    "value": 1
                                },
                                {
                                    "source": "XY",
                                    "type": "Colorsource"
                                },
                                {
                                    "x": 0.14753297508549096,
                                    "y": 0.13727405959941377,
                                    "rgb": "rgb(136, 255, 255)",
                                    "type": "Color"
                                },
                                {
                                    "tw": 23.52941,
                                    "min": 2700,
                                    "max": 6000,
                                    "type": "CCT",
                                    "value": 6000,
                                    "level": 1
                                }
                            ]
                        ],
                        "dimLevel": 1,
                        "type": "Luminaire"
                    },
                },
                "scenes": {
                    "1": {
                        "name": "Timer",
                        "id": 1,
                        "position": 0,
                        "icon": 0,
                        "color": "#FFFFFF",
                        "type": "REGULAR",
                        "hidden": false,
                        "units": {
                            "12": {
                                "id": 12
                            }
                        }
                    },
                    "4": {
                        "name": "Presence",
                        "id": 2,
                        "position": 1,
                        "icon": 0,
                        "color": "#06FF29",
                        "type": "REGULAR",
                        "hidden": false,
                        "units": {
                            "18": {
                                "id": 18
                            }
                        }
                    }
                },
                "groups": {
                    "3": {
                        "id": 3,
                        "name": "Demo Group",
                        "position": 2,
                        "units": [
                            {
                                "0": 12,
                                "position": 0
                            }
                        ]
                    }
                }
            }
        },
        {
            method: "GET",
            path: "/v1/networks/{id}/groups",
            title: "Request network groups",
            params: {"id":""},
            inputHelp: { "id": "networkId"},
            help: 'Retrieves information of groups in network identified by network ID, requires use of API key and sessionId (Header: X-Casambi-Key, X-Casambi-Session). ',
            responseExample: {
                "3": {
                    "id": 3,
                    "name": "Demo Group",
                    "position": 2,
                    "units": [
                        {
                            "id": 12,
                            "position": 0
                        }
                    ]
                }
            }
        },
        {
            method: "GET",
            path: "/v1/networks/{id}/scenes",
            title: "Request network scenes",
            params: {"id":""},
            inputHelp: { "id": "networkId"},
            help: 'Retrieves information of scenes in network identified by network ID, requires use of API key and sessionId (Header: X-Casambi-Key, X-Casambi-Session). ',
            responseExample: {
                "1": {
                    "name": "Timer",
                    "id": 1,
                    "position": 0,
                    "icon": 0,
                    "color": "#FFFFFF",
                    "type": "REGULAR",
                    "hidden": false,
                    "units": {
                        "12": {
                            "id": 12
                        }
                    }
                },
                "4": {
                    "name": "Presence",
                    "id": 2,
                    "position": 1,
                    "icon": 0,
                    "color": "#06FF29",
                    "type": "REGULAR",
                    "hidden": false,
                    "units": {
                        "18": {
                            "id": 18
                        }
                    }
                }
            }
        },
        {
            method: "GET",
            path: "/v1/networks/{id}/datapoints",
            title: "Request network datapoints",
            params: {"id":""},
            inputHelp: {"id": "networkId" },
            filterHelp: {
                "sensorType": "0 = casambi | 1 = vendor => int value, deprecated **use dataType instead!",
                "dataType": "sensors | vendor | control | energy | details | status",
                "keys": 'dimmer, lux, presence, battery_level, etc.. => string value or array e.g. "lux" or ["lux", "battery_level", "presence"]',
                "units": '[15, 22, etc..] => unit id or array of unit id\'s e.g. 15 or [15, 22] **optional',
                "from": "yyyyMMdd[hh[mm[ss]]]",
                "to": "yyyyMMdd[hh[mm[ss]]]" },
            filterExample: { "dataType": "control", "keys": "dimmer", "units": 15, "from": 20200310, "to": 20200317 },
            filterOptionsRequired: true,
            help: 'Retrieves list of sensor data (sensor/luminaire) in network identified by network ID and filtered by data type or data keys and time range. \
            Additionally can be filtered by unit id\'s as well (optional). Requires use of API key and sessionId (Header: X-Casambi-Key, X-Casambi-Session). \
            Filtering parameters dataType or keys and from and to are mandatory. Time range can be given as a date with or without hours, minutes and seconds. \
            The maximum time range is 7 days. If range is exceeded response will return HTTP status code 416 - Requested Range Not Satisfiable. \
            If given filter values are invalid or mandatory value is missing will return HTTP status code 400 - Bad Request.',
            consoleNote: 'Note: filtering values dataType (or keys) and from and to are mandatory! \
            Filter options are expected as GET request parameters => "URL?dataType=sensors&from=20190723&to=20190729" etc..',
            responseExample: [
                {
                    "unit": 15,
                    "sensor": "lux",
                    "value": 255,
                    "time": "20190724072154"
                },
                {
                    "unit": 15,
                    "sensor": "presence",
                    "value": 0,
                    "time": "20190724132540"
                },
                {
                    "unit": 22,
                    "sensor": "battery_level",
                    "value": 0,
                    "time": "20190725063204"
                }
            ],
            updates: ["13.05.2020: updated to use string based data type filter values, int based sensor type filter values are deprecated."]

        },
        {
            method: "GET",
            path: "/v1/networks/{networkId}/units/{unitId}/icon",
            title: "Request network unit icon",
            params: {"networkId":"", "unitId":""},
            inputHelp: { "networkId": "networkId", "unitId": "unitId"},
            help: 'Retrieve unit icon (or fixture icon if unit image not set) identidied by network and unit ID, requires use of API key and sessionId (Header: X-Casambi-Key, X-Casambi-Session). Will return image blob data in png format or HTTP status 404 Not found. ',
            responseExample: "BLOB:ImageData(png)"
        },
        {
            method: "GET",
            path: "/v1/networks/{id}/gallery",
            title: "Request network gallery",
            params: {"id":""},
            inputHelp: { "id": "networkId"},
            help: 'Retrieves gallery information (photo list) of network identified by network ID, requires use of API key and sessionId (Header: X-Casambi-Key, X-Casambi-Session). ',
            responseExample: [
                {
                    "name": "Photo",
                    "controls": [],
                    "image": "iR4aIP3vXcB348Pijif2d4Y7AnowFbdD",
                    "position": 0
                },
                {
                    "name": "Photo",
                    "controls": [],
                    "image": "KLejfitLiEFeiUnhak6ID69VzJhvWYER",
                    "position": 1
                }
            ]
        },
        {
            method: "GET",
            path: "/v1/networks/{networkId}/images/{imageId}",
            title: "Request network image",
            params: {"networkId": "", "imageId": ""},
            inputHelp: { "networkId": "networkId", "imageId": "imageId"},
            help: 'Retrieves image identified by network and image ID, requires use of API key and sessionId (Header: X-Casambi-Key, X-Casambi-Session). Will return image blob data in png format or HTTP status 404 Not found. ',
            responseExample: "BLOB:ImageData(png)"
        },

        "_______ Casambi public API Fixture _______",

        {
            method: "GET",
            path: "/v1/fixtures/{id}",
            title: "Request fixture information",
            noSessionKey: true,
            params: { "id": "" },
            inputHelp: { "id": "fixtureId"},
            help: 'Retrieves fixture information identified by fixture ID, requires use of API key (Header: X-Casambi-Key). ',
            responseExample: {
                "id": 23456,
                "type": "Driver",
                "vendor": "Oktalite Lichttechnik GmbH",
                "model": "Oktalite AGIRA PLUS",
                "translations": {},
                "controls": [
                    {
                        "type": "button",
                        "name": "Button",
                        "buttonLabel": "Button",
                        "dataname": "button",
                        "id": 0,
                        "readonly": true
                    },
                    {
                        "type": "dimmer",
                        "id": 1,
                        "readonly": false
                    },
                    {
                        "type": "rgb",
                        "id": 7,
                        "readonly": false
                    },
                    {
                        "type": "temperature",
                        "id": 25,
                        "readonly": false
                    },
                    {
                        "type": "colorsource",
                        "id": 31,
                        "readonly": false
                    },
                    {
                        "type": "slider",
                        "name": "Slider",
                        "unit": "",
                        "id": 33,
                        "readonly": false,
                        "valueType": "FLOAT"
                    }
                ]
            }
        },
        {
            method: "GET",
            path: "/v1/fixtures/{id}/icon",
            title: "Request fixture icon",
            noSessionKey: true,
            params: { "id": "" },
            inputHelp: { "id": "fixtureId"},
            help: 'Retrieves fixture icon identified by fixture ID, requires use of API key (Header: X-Casambi-Key). Will return image blob data in png format or HTTP status 404 Not found. ',
            responseExample: "BLOB:ImageData(png)"
        }
    ];

